﻿using System.Data;
using System;
using System.ComponentModel;
using System.Collections.Generic;
using System.Linq;
using System.Drawing;
using System.Web;
using System.Web.UI.WebControls;
using System.Text;
using System.Web.UI;
using System.Collections;

namespace Marbles.Core.Web.Controls
{
    [ToolboxData("<{0}:DynamicContent runat=server></{0}:DynamicContent>")]
    public class DynamicContent : Panel 
    {

        [Category("Appearance")]
        public string InnerHtml
        {
            get { return ContentObject.Value; }
        }

        [Category("Appearance")]
        public CMS.ContentObject ContentObject
        {
            get { object obj = ViewState["ContentObject"]; if (obj == null) { ViewState["ContentObject"] = new CMS.ContentObject(); } return ViewState["ContentObject"] as CMS.ContentObject; }
            set { ViewState["ContentObject"] = value; }
        }

        protected override void CreateChildControls()
        {
            System.Web.UI.HtmlControls.HtmlGenericControl ctl = new System.Web.UI.HtmlControls.HtmlGenericControl();
            ctl.InnerHtml = this.InnerHtml;
            ctl.ID = this.ContentObject.Key;
            this.Controls.Add(ctl);
        }
    }
}
